/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package controller;

import common.Articulo;
import common.Hogar;
import common.ItemTabla;
import common.Ropa;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.swing.JPanel;
import tiendagui.internal.JDialogArticulo;
import tiendagui.internal.paneles.JPanelAccesorios;
import tiendagui.internal.paneles.JPanelRopas;

/**
 *
 * @author Jhonny
 */
public class ControllerArticulo extends Controller{

    private JDialogArticulo     dialog;
    private Articulo            articulo;
    public ControllerArticulo(JDialogArticulo dialog) {
        super();
        this.dialog = dialog;
    }

    public void setArticulo(Articulo item){
        this.articulo = item;
    }

    @Override
    public void initComponentView() throws FileNotFoundException, IOException {
        dialog.getPanelTipo().removeAll();
        if(articulo!=null){
            JPanel panel=null;
            if(articulo instanceof Ropa){
                panel = new JPanelRopas();
                
            }else if(articulo instanceof Hogar){
                panel= new JPanelAccesorios();
            }
            dialog.getPanelTipo().add(panel);
        }
    }

    @Override
    public void cerrar() {
        dialog.setVisible(false);
    }

}
